// 已弃用
console.log('geturlstate.js running')
// 假设你有一个包含链接的数组  
const links = [
    { href: 'http://122.152.204.102:912', name: "Shard核弹监视", id: "nuker" },
    { href: 'http://122.152.204.102:9959', name: "可道云", id: "pan" },
    { href: 'http://122.152.204.102:11111', name: "无尽任务", id: "pq" },
    { href: 'http://122.152.204.102:20418', name: "日记本", id: "riji" },
    { href: 'http://122.152.204.102:20419', name: "白色相簿", id: "xiangce" },
    { href: 'http://122.152.204.102:20420', name: "体育计算器", id: "tiyu" },
    // { href: 'http://122.152.204.102:20423', name: "PDF工具", id: "pdf" },
    { href: 'http://api-screeps.mofengfeng.com/api/portals/find_route?from=shard0_W1N1&to=shard3_W2N2', name: "Mofeng星门寻路", id: "mffapi" },

    { href: 'https://api.zsuuu.com', name: "自制接口", id: "api" },
    { href: 'https://api.zsuuu.com', name: "Mofeng星门寻路(https转发)", id: "mffapihttps" },
    { href: 'https://screeps-cn.github.io', name: "Screeps文档api", id: "screepsapi" },
    { href: 'https://www.zsuuu.com/download.html', name: "安卓版Screeps下载", id: "screepsdownload" },

];

links.forEach(async (link) => {
    try {
        // 构造包含查询参数的URL  
        const apiUrl = `https://api.zsuuu.com/checkurl?url=${encodeURIComponent(link.href)}`;

        // 使用fetch API发送请求  
        const response = await fetch(apiUrl);

        // 检查响应状态码  
        if (!response.ok) {
            // console.log(`HTTP error! status: ${response.status}`);
            return
        }

        // 解析JSON响应  
        const data = await response.json();

        // 输出结果或进行其他操作  
        // console.log(data);
        if (data.status_code == 200) {
            try {
                document.getElementById(link.id).style.backgroundColor = "green"
                // console.log(link.name, "√")
            } catch (error) {
                // console.log(link.name, "X",error)
            }
        }
    } catch (error) {
        console.log(link.name, error);
    }
});
